package com.uinnova.springboot.demo.mongodb;

import com.uinnova.springboot.demo.kit.Retkit;
import com.uinnova.springboot.demo.mongodb.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @author 张攀钦
 * @date 2018-12-25-23:45
 * ${DES}
 */
@RestController
@Api
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation(value = "测试 swagger")
    @GetMapping(value = "/jail/user/{id}")
    public Retkit<User> getUserById(@PathVariable String id) {
        Retkit<User> ok = Retkit.ok();
        return ok.data(userService.getUserById(id));
    }
    @ApiIgnore
    @GetMapping(value = "/jail/user/name/{name}")
    public Retkit<User> getUserByName(@PathVariable String name) {
        Retkit<User> ok = Retkit.ok();
        return ok.data(userService.getUserByName(name));
    }
    @GetMapping(value = "/jail/user/form/{name}")
    public Retkit<User> getUserFromName(@PathVariable String name) {
        Retkit<User> ok = Retkit.ok();
        return ok.data(userService.findFromName(name));
    }

}
